#!/bin/sh 

source config

echo "from " $startdate "to " $enddate "to read " $alldays

##commcode bookheader > index_readcal.md 

echo "" > index_readcal.md

echo "<center>"$bookname"</center>\n" >> index_readcal.md

echo "<center>从" $startdate "到" $enddate "共" $alldays "</center>" >>index_readcal.md


echo "" >>index_readcal.md

for files in `no $allchapter`
do
	prefix=$tag$files"_"
	
	ls -l $prefix*.md >tmp.md

	startdate=`sed -e "/^l/d" tmp.md |sed -e "s/.*_//" |sed -e "s/-.*//g"`
	readday=`wc tmp.md |awk '{print $1}'`
	chapter=`cat $prefix$startdate*.md |grep "^#### "|sed -e "s/#### //g"`
	echo $startdate ": ["$chapter"]("$tag$files".html)"  $readday "天" >>index_readcal.md
	echo "" >>index_readcal.md
done

rm -f tmp.md

